﻿using Box2DSharp.Common;
using OpenTK.Mathematics;

namespace TrinityEngine
{
    public class Transform
    {
        public Vector3 position { get; set; } = Vector3.zero;

        public Vector3 eulerAngles
        {
            get => _rotation.ToEulerAngles();
            set => _rotation = new Quaternion(value * Mathf.Deg2Rad);
        }

        public Quaternion rotation
        {
            get => _rotation;
            set => _rotation = value;
        }
        private Quaternion _rotation = Quaternion.Identity;

        public Vector3 scale { get; set; } = Vector3.one;

        public Matrix4 localToWorldMatrix =>
            Matrix4.CreateScale(scale) *
            Matrix4.CreateFromQuaternion(rotation) *
            Matrix4.CreateTranslation(position);
    }
}
